// https://www.hackerrank.com/challenges/taum-and-bday#include <math.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <assert.h>#include <limits.h>#include <stdbool.h>long res;int main(){    int t;    scanf("%d",&t);    while(t--){        long b;        long w;        scanf("%ld %ld",&b,&w);        long x;        long y;        long z;        scanf("%ld %ld %ld",&x,&y,&z);        res = 0;        res += x+z<y ? w*(x+z) : w*y;        res += y+z<x ? b*(y+z) : b*x;        printf("%ld\n",res);    }    return 0;}